﻿namespace Koala.Pro.Core.Dto;

public class PagedAndSortedInputDto : PagedInputDto, ISortedResultRequest
{
    public string? Sorting { get; set; }

    public PagedAndSortedInputDto()
    {
        MaxResultCount = int.MaxValue;
    }

    public PagedAndSortedInputDto(int skipCount, int resultCount)
    {
        SkipCount = skipCount;
        MaxResultCount = resultCount;
    }

    public PagedAndSortedInputDto(PagerInfo pagerInfo)
    {
        if (pagerInfo != null)
        {
            int num = pagerInfo.PageSize > 0 ? pagerInfo.PageSize : 50;
            SkipCount = num * ((pagerInfo.CurrentPageIndex <= 0 ? 1 : pagerInfo.CurrentPageIndex) - 1);
            MaxResultCount = num;
        }
    }
}